AC_INIT([wtk], [0.0.0])
AC_CONFIG_AUX_DIR([acaux])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADERS([config.h:config.h.in])
AM_INIT_AUTOMAKE

: ${CXXFLAGS:=-Wall -std=c++20}

AC_PROG_CXX
LT_INIT([win32-dll])

AC_PROG_LN_S
AC_PROG_MKDIR_P

AC_SUBST([fontsdir], ['${pkgdatadir}/fonts'])
AC_SUBST([pkgconfigdir], ['${libdir}/pkgconfig'])

# --enable-debug
AC_ARG_ENABLE(
    [debug],
    AS_HELP_STRING([--enable-debug], [Enable debug @<:@default=yes@:>@]),
    [wtk_enable_debug=${enableval}],
    [wtk_enable_debug=yes]
)

AS_CASE(
    [${wtk_enable_debug}],
    [yes], [wtk_debug_flags='-g -O0 -DWTK_DEBUG'],
    [no],  [wtk_debug_flags='-O2 -DNDEBUG'],
    [AC_MSG_ERROR([wtk_enable_debug: wrong value: ${wtk_enable_debug}])]
)

# --enable-gprof
AC_ARG_ENABLE(
    [gprof],
    AS_HELP_STRING([--enable-gprof], [Enable gprof compile flags @<:@default=no@:>@]),
    [wtk_enable_gprof=${enableval}],
    [wtk_enable_gprof=no]
)

AS_CASE(
    [${wtk_enable_gprof}],
    [yes], [wtk_gprof_flags='-pg'; wtk_gprof_libs='-pg'],
    [no],  [wtk_gprof_flags=''; wtk_gprof_libs=''],
    [AC_MSG_ERROR([wtk_enable_gprof: wrong value: ${wtk_enable_gprof}])]
)

# --enable-boost
AC_ARG_ENABLE(
    [boost],
    AS_HELP_STRING([--enable-boost], [Enable use of boost libs @<:@default=yes@:>@]),
    [wtk_enable_boost=${enableval}],
    [wtk_enable_boost=yes]
)

AX_BOOST_BASE([1.63])

#
AS_CASE(
    [${host}],
    [*-mingw32], [wtk_static_gcc_ldflags='-static-libgcc -static-libstdc++'],
    [wtk_static_gcc_ldflags='']
)

AC_SUBST([WTK_CFLAGS], ["$wtk_debug_flags $wtk_gprof_flags"])
AC_SUBST([WTK_LDFLAGS], ["$wtk_static_gcc_ldflags"])
AC_SUBST([WTK_LIBS], ["$wtk_gprof_libs"])

PKG_CHECK_MODULES([WGL], [wgl])

AC_CONFIG_FILES([ \
  wtk.pc \
  Makefile \
  wtk/Makefile \
  data/Makefile \
  data/fonts/Makefile \
])
AC_OUTPUT
